package com.ostrich.module_home.discovery.adapter.provider

import com.chad.library.adapter.base.provider.BaseItemProvider
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.ostrich.module_home.R
import com.ostrich.module_home.discovery.entity.DiscoveryEntity
import com.ostrich.module_home.discovery.viewholder.CustomBannerViewHolder
import com.zhpan.bannerview.BannerViewPager
import com.zhpan.bannerview.constants.PageStyle
import com.zhpan.bannerview.holder.HolderCreator

/**
 * @Author : yaotianxue
 * @Time : On 2023/10/30 16:15
 * @Description : TopBannerProvider
 */
class TopBannerProvider(override val itemViewType: Int, override val layoutId: Int) :BaseItemProvider<DiscoveryEntity>(),HolderCreator<CustomBannerViewHolder> {
    override fun convert(helper: BaseViewHolder, item: DiscoveryEntity) {
        //轮播图
        val bannerViewPager = helper.getView<BannerViewPager<DiscoveryEntity, CustomBannerViewHolder>>(R.id.top_bv)
        bannerViewPager.setPageStyle(PageStyle.MULTI_PAGE_OVERLAP)
            .setHolderCreator(this)
            .create(item.data.itemList)
    }

    override fun createViewHolder(): CustomBannerViewHolder {
        return CustomBannerViewHolder()
    }
}